<template>
	<!-- 我的许愿 -->
	<view class="muWish">
		<u-sticky>
			<u-tabs :list="list" active-color="#FA9700" :is-scroll="false" :current="current" @change="change"></u-tabs>
		</u-sticky>
		<view class="muWish_content">
			<view-NoData v-if="wishList.length==0">
				
			</view-NoData>
			<!-- 权益许愿 -->
			<view class="muWish_content_one" v-for="(item,index) in wishList" :key="index"
			@click="jump(item)"
			>
				<view class="muWish_content_one_left">
					<view class="left_oneTitle">
						{{item.mountains_name}}
					</view>
					<view class="left_oneTime">
						{{item.create_time}}
					</view>
				</view>
				<view class="muWish_content_one_right">
					<image v-if="current==0" src="../../static/ys.png" mode="aspectFill"></image>
					<image v-if="current==1" style="width: 48rpx;height: 61rpx;" src="../../static/xinsuo.png" mode="aspectFill"></image>
					<view class="muWish_content_one_rightTitle">
						关注量：{{item.mountains_concern}}
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getWishingList
	} from "@/common/config/request.js"
	export default {
		data() {
			return {
				list: [{
					name: '权益许愿'
				}, {
					name: '真实许愿'
				}],
				current: 0,
				wishList:[],
				pageNum: 1,
				totalPage: 0, //总页数
			}
		},
		onLoad() {
			// 获取许愿列表
			this.Wishing()
		},
		methods: {
			Wishing() {
				let data = {
					type: this.current,
					page: this.pageNum
				}
				getWishingList(data).then(res => {
					console.log(res)
					if(res.data.code==1){
						this.totalPage=res.data.data.last_page
						this.wishList=[...this.wishList,...res.data.data.data]
					}
				})
			},
			change(index) {
				console.log(index)
				this.current = index;
				this.pageNum=1
				this.wishList=[]
				this.Wishing()
			},
			jump (item) {
				uni.navigateTo({
					url: '../wish/wishDetail?id=' + item.mountains_id 
				})
			}
		},
		onReachBottom() {
			if (this.pageNum < this.totalPage) {
				this.pageNum++
				this.getYU()
			} else {
				uni.showToast({
					icon: 'none',
					title: '暂无更多数据'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.muWish {
		width: 750rpx;
		min-height: 100vh;
		background-color: #F3F4F5;

		.muWish_content {
			width: 750rpx;
			box-sizing: border-box;
			padding: 20rpx;

			.muWish_content_one {
				width: 710rpx;
				height: 169rpx;
				border-radius: 20rpx;
				background-color: #FFFFFF;
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin-bottom: 20rpx;

				.muWish_content_one_left {
					margin-left: 30rpx;

					.left_oneTitle {
						font-size: 34rpx;
						font-family: PingFang SC;
						font-weight: 400;
						color: #333333;
					}

					.left_oneTime {
						font-size: 28rpx;
						font-family: PingFang SC;
						font-weight: 400;
						color: #CCCCCC;
						margin-top: 20rpx;
					}
				}

				.muWish_content_one_right {
					width: 280rpx;
					text-align: center;

					image {
						width: 104rpx;
						height: 75rpx;
					}

					.muWish_content_one_rightTitle {
						font-size: 28rpx;
						font-family: PingFang SC;
						font-weight: 400;
						color: #666666;
					}
				}
			}
		}
	}
</style>
